package com.helloworld.fiberflax.inventory;

import com.helloworld.fiberflax.Fiberflax;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.SlotItemHandler;

public class ContainerFiberflaxBag extends Container {
    private final ItemStackHandler items = new ItemStackHandler(9);
    public ContainerFiberflaxBag(EntityPlayer player) {
        super();
        for (int i = 0; i < 9; ++i) {
            this.addSlotToContainer(new SlotItemHandler(items, i, 8 + i * 18, 18));
        }

        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 9; ++j) {
                this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 48 + i * 18));
            }
        }

        for (int i = 0; i < 9; ++i) {
            this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 106));
        }
    }

    @Override
    public boolean canInteractWith(EntityPlayer playerIn) {
        /*检查玩家是不是手持一个亚麻袋*/
        return new ItemStack(Fiberflax.fiberflaxBag).isItemEqual(playerIn.getHeldItemMainhand());
    }

    @Override
    public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
    {
        return null;
    }
}
